
circles = [];
r = 100;
GFX.clear();
for (var i=0;i<20;i++)    {
    circles[i] = GFX.createEllipse({ cx: 0, cy: 0, rx: r, ry: r });

    var fillObj = { colors: [ { offset: .8, color: [0,100,Math.random()*100+108,Math.random()] }, { offset: 1, color: [0,0,48,0.5] } ] };
    circles[i].setFill(dojo.mixin({ type: "radial", cx: 0, cy:  0, r: r }, fillObj));	
}		
		
LAYER0.addTo("gradientcircles", function()    {
    
    var speed = 5;
    // calculates the new position based on the FRAMECOUNTER
    var alphaoffset = (FRAMECOUNTER/1000 % 20)*speed;
    var alpha = 0;
    var spectrum = document.applet.getSpectrum();
    // transforms the rect
    dojo.forEach( circles, function(c,i)    {
	alpha+=180/Math.PI;
	var x= Math.cos(alpha+alphaoffset*i)*Math.sin(alpha+alphaoffset)*400+400;
	var y= Math.cos(alpha+alphaoffset*i)*200+300;	
        var xx = spectrum[i%64+1]/1000;
        var red = spectrum[i%64+1]*100;
		
	c.setTransform({yy: xx, xx: xx, dx: x, dy: y});		


    });

});


